package com.qf.controller;


import com.qf.bean.AjaxMessage;
import com.qf.entity.Course;
import com.qf.entity.CourseTeacher;
import com.qf.service.ICourseDetailsService;
import com.qf.service.ICourseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author lcx
 * @since 2020-09-03
 */
@RestController
@RequestMapping("/course")
public class CourseController {
    @Autowired
    ICourseService courseService;

    @RequestMapping("/recommend")
    public AjaxMessage selectAllCourse(){
        List<CourseTeacher> courses = courseService.selectCourseBy(new Course());
        if (courses != null && courses.size() != 0){
            return new AjaxMessage(0,"",courses);
        }
        return new AjaxMessage(1,"查询失败");
    }

    @RequestMapping("/select")
    public AjaxMessage selectCourseBy(Course course){
        List<CourseTeacher> courses = courseService.selectCourseBy(course);
        if (course != null && courses.size() != 0){

            return new AjaxMessage(0,"",courses);
        }
        return new AjaxMessage(1,"查询失败");
    }
}
